/**
 * 
 */

function buildPageInfo(){
	
	var pageCount = jQuery("#page_count").val()/1;
	if(pageCount <= 1){
		return "";
	}
	
	var page = jQuery("#page").val()/1;
	var html = "<a href='javascript:var s=1' onclick='panoramaPrevPage()' >上一页</a>&nbsp;&nbsp;";
	
	if(pageCount <= 6){
		html += buildPageIndexBtn(page, 1, pageCount);
	}else{
		var midIndex = pageCount/2; 
		
		if(page < 6 && page <= midIndex){
			html += buildPageIndexBtn(page, 1, page+1);
		}else{
			html += buildPageIndexBtn(page, 1, 2);
		}
		
		html += "&nbsp;...&nbsp;";
		
		if(page >= 6 && pageCount-page > 4){
			html += buildPageIndexBtn(page, page-1, page+1);
			html += "&nbsp;...&nbsp;";
			html += buildPageIndexBtn(page, pageCount-1, pageCount);
		}else if(page > midIndex && pageCount - page <= 4){
			html += buildPageIndexBtn(page, page-1, pageCount);
		}else{
			html += buildPageIndexBtn(page, pageCount-1, pageCount);
		}
		
	}
	
	html += "&nbsp;&nbsp;<a href='javascript:var s=1' onclick='panoramaNextPage()' >下一页</a>";
	jQuery('#pageinfo').html(html);
}

function buildPageIndexBtn(selectIndex, start, end){
	var t = "";
	end = end/1;
	for(var i = start/1; i <= end; i++){
		if(selectIndex == i){
			t += "<a href='javascript:void(0)' onclick='showPanoramaContent("+i+")' >&nbsp;" + i + "&nbsp;</a>"
		}else{
			t += "<a href='javascript:void(0)' onclick='showPanoramaContent("+i+")' >&nbsp;[" + i + "]&nbsp;</a>"	
		}
	}
	
	return t;
}
